package com.yunhe.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.dao.NewsMapper;
import com.yunhe.factory.MySqlSessionFactory;
import com.yunhe.javabean.News;


public class NewsServiceImp implements NewsService {
	public static void main(String[] args) {
		NewsServiceImp nsi=new NewsServiceImp();
		List<News>newsList=nsi.searchNews("java");
		System.out.println(newsList);
	}

	@Override
	public List<News> searchNews(String title) {
		// TODO Auto-generated method stub
		SqlSession session=MySqlSessionFactory.getSessionFactory().openSession();
		NewsMapper mapper=session.getMapper(NewsMapper.class);
		  List<News> newsList=mapper.selectNewsByCondition(title);
		  session.close();
		return newsList;
	}

}
